import axios from 'axios'
const reqPaging=(page,limit)=>{
    return axios({
        method:'GET',
        url:'http://localhost:3000/users',
        params:{
            _page:page,
            _limit:limit,
        }
    })
}
const reqAllUsers=()=>{
    return axios({
        method:'GET',
        url:'http://localhost:3000/users',
    })
}
const reqAddUsers=(user)=>{
    return axios({
        method:'POST',
        url:'http://localhost:3000/users',
        data:{
            ...user,
            createTime:Date.now(),
            updateTime:Date.now()
        }
    })
}
const reqGetUpdateUsers=(id)=>{
    return axios({
        method:'GET',
        url:`http://localhost:3000/users/${id}`,
    })
}
const reqUpdateUser=(user)=>{
    return axios({
        method:'PATCH',
        url:`http://localhost:3000/users/${user.id}`,
        data:{
            nickname:user.nickname,
            password:user.password,
            updateTime:Date.now()
        }
    })
}
const reqDeleteUser=(id)=>{
    return axios({
        method:'DELETE',
        url:`http://localhost:3000/users/${id}`,
    })
}
export {reqPaging,reqAllUsers,reqAddUsers,reqGetUpdateUsers,reqUpdateUser,reqDeleteUser}